version 17.0					
set more off					
  quietly log					
  local logon = r(status)
  if "`logon'" == "on" { 		
	log close
	}	
log using dd_laspisa_finalanalysis, text replace	

/******************************************************************************/
/* Author:			Chase LaSpisa						                      */
/* Date:			October 15th, 2024					  	                  */
/* File:			dd_laspisa_dataandanalysis_10.15.24.do	                  */
/* Purpose:		    Replication Material for Dangerous Development			  */
/* Input File:	    dd_updateddataset_6.12.24								  */
/* Output File:	    dd_laspisa_ (.rtf,.gph,etc.) 				              */
/* NOTE: Tables and figures require Estout and Coefplot software in Stata.    */
/* Please see the README file for instructions on how to install these.       */
/******************************************************************************/

clear all

use "dd_updateddataset_10.15.24.dta"


*** Main Analysis ***

** Dyad Discovery Models **

*Table 1 Model 1 
logit mariss3 oildiscoverydyad dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust
estimates store oildisc1

* Table 1 Model 2
logit mariss3 oildiscdyadyears2 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust
estimates store oildisc2


*Table 1 Model 3
logit mariss3 oildiscdyadyears3 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust
estimates store oildisc3


** Dyad Production Models **
*Table 1 Model 4
logit mariss3 oilproductiondyad dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust
estimates store oilprod1


*Table 1 Model 5
logit mariss3 oilproduction5 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust
estimates store oilprod2


** Making Table 1 **
esttab oildisc1 oildisc2 oildisc3 oilprod1 oilprod2 ///
	using dd_laspisa_table1.rtf, replace compress b(%9.3f) ///
	se transform(ln*: exp(2*@) exp(2*@)) stats(N ll,fmt("%9.0fc")) ///
	star(* .05 ** .01 *** .001) ///
	mlabel("Discovery(Y)" "Discovery(A)" "Discovery(E)" "Production(Y)" "Production(E)") ///
	order(oildiscoverydyad oildiscdyadyears2 oildiscdyadyears3 oilproductiondyad oilproduction5 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast) ///
	label ///
	title("Table 1: Offshore Fossil-Fuel Development and Maritime Diplomatic Claim Occurrence, 1900-2007")

** Predicted Probabilities for Model 2 **
quietly logit mariss3 oildiscdyadyears2 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year)

margins, at(oildiscdyadyears2=(0(1)1)) atmeans vsquish

marginsplot, scheme(s1color) graphregion(col(white)) ///
	derivlab bgcol(white) plot1opts(mcolor(navy)) recast(scatter) ciopt(color(blue%40)) ///
	title("") ///
	ytitle("Probality of Maritime Conflict") ///
	caption("Note: Values are predicted probabilities based on logistic regression coefficients" /// 
	"with other variables held constant at mean values. The graph includes the 95% CI around the" /// 
	"prediction of the outcome variable.", size(small)) ///
	saving(dd_laspisa_marginsplot_fig1, replace)
	
	graph export dd_laspisa_fig1.png, as(png) replace

** Predicted Probabilities for Model 5 **	
quietly logit mariss3 oilproduction5 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year)

margins, at(oilproduction5=(0(1)1)) atmeans vsquish

marginsplot, scheme(s1color) graphregion(col(white)) ///
	derivlab bgcol(white) plot1opts(mcolor(navy)) recast(scatter) ciopt(color(blue%40)) ///
	title("") ///
	ytitle("Probality of Maritime Conflict") ///
	caption("Note: Values are predicted probabilities based on logistic regression coefficients" /// 
	"with other variables held constant at mean values. The graph includes the 95% CI around the" /// 
	"prediction of the outcome variable.", size(small)) ///
	saving(dd_laspisa_marginsplot_fig2, replace)
	
	graph export dd_laspisa_fig2.png, as(png) replace

	
	
***** Appendix *****

*** Summary Statistics ***
estpost summarize mariss3 oildiscoverydyad oildiscdyadyears2 oildiscdyadyears3 oilproductiondyad oilproduction5 dyaddem mixeddyad relcapenergy majpow cwmid navpower americas europe asia middleeast
estimates store summstats

esttab summstats using dd_laspisa_tablea1.rtf, ///
	replace label cell("count mean var sd min max sum") main(count %6.2f mean %6.2f var %6.2f sum %6.2f) aux(sd min max)  ///
	title("Table A1: Summary Statistics")
	
*** Correlation Matrix ***	
quietly estpost correlate oildiscoverydyad oildiscdyadyears2 oildiscdyadyears3 oilproductiondyad oilproduction5, matrix listwise
est store correlation

esttab correlation using dd_laspisa_tablea2.rtf, replace label unstack not noobs compress ///
	title("Table A2: Correlation Matrix")
		
	
		
*** Robustness Checks ***
** Controlling for Production and Discovery **
logit mariss3 oildiscoverydyad oilproductiondyad dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust
estimates store oildiscA1

logit mariss3 oildiscdyadyears2 oilproductiondyad dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust
estimates store oildiscA2

logit mariss3 oildiscdyadyears3 oilproductiondyad dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust
estimates store oildiscA3

logit mariss3 oilproduction5 oildiscoverydyad dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust
estimates store oilprodA4

esttab oildiscA1 oildiscA2 oildiscA3 oilprodA4  ///
	using dd_laspisa_tableA3.rtf, replace compress b(%9.3f) ///
	se transform(ln*: exp(2*@) exp(2*@)) stats(N ll,fmt("%9.0fc")) ///
	star(* .05 ** .01 *** .001) ///
	mlabel("Discovery(Y)" "Discovery(A)" "Discovery(E)" "Production(E)") ///
	order(oildiscoverydyad oildiscdyadyears2 oildiscdyadyears3 oilproductiondyad oilproduction5 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast) ///
	label ///
	title("Table A3: Offshore Fossil-Fuel Development and Maritime Diplomatic Claim Occurrence, 1900-2007")

** Rare Events Logit **
relogit mariss3 oildiscoverydyad dyaddem mixeddyad relcapenergy majpow cwmid navpower  unclosforce americas europe asia middleeast, cluster(year)
estimates store oildisc1appRare

relogit mariss3 oildiscdyadyears2 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year)
estimates store oildisc2appRare

relogit mariss3 oildiscdyadyears3 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year)
estimates store oildisc3appRare

relogit mariss3 oilproductiondyad dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year)
estimates store oilprod1appRare
	
relogit mariss3 oilproduction5 dyaddem mixeddyad relcapenergy majpow cwmid navpower  unclosforce americas europe asia middleeast, cluster(year)
estimates store oilprod5appRare
	
esttab oildisc1appRare oildisc2appRare oildisc3appRare oilprod1appRare oilprod5appRare ///
	using dd_laspisa_tableA4.rtf, replace compress b(%9.3f) ///
	se transform(ln*: exp(2*@) exp(2*@)) stats(N ll,fmt("%9.0fc")) ///
	star(* .05 ** .01 *** .001) ///
	mlabel("Discovery(Y)" "Discovery(A)" "Discovery(E)" "Production(Y)" "Production(E)") ///
	order(oildiscoverydyad oildiscdyadyears2 oildiscdyadyears3 oilproductiondyad oilproduction5 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast) ///
	label ///
	title("Table A4: Offshore Fossil-Fuel Development and Maritime Diplomatic Claim Occurrence, 1900-2007")


** Effect of Maritime Claims on Offshore Oil Discovery/Production **
* Claim on Discovery *
logit oildiscoverydyad L.mariss3 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust
estimates store lagclaimonoildisc1
logit oildiscoverydyad L10.mariss3 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust

logit oildiscoverydyad L5.mariss3 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust
estimates store lagclaimonoildisc5

logit oildiscdyadyears2 L.mariss3 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust
logit oildiscdyadyears2 L5.mariss3 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust

logit oildiscdyadyears3 L.mariss3 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust
logit oildiscdyadyears3 L5.mariss3 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year) robust

* Claim on Production *
logit oilproductiondyad L1.mariss3 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year)
estimates store lagclaimonoilprod1
logit oilproductiondyad L5.mariss3 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year)
estimates store lagclaimonoilprod5

logit oilproduction5 L1.mariss3 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year)
logit oilproduction5 L5.mariss3 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast, cluster(year)

esttab lagclaimonoildisc1 lagclaimonoildisc5 lagclaimonoilprod1 lagclaimonoilprod5 ///
	using dd_laspisa_tableA5.rtf, replace compress b(%9.3f) ///
	se transform(ln*: exp(2*@) exp(2*@)) stats(N ll,fmt("%9.0fc")) ///
	star(* .05 ** .01 *** .001) ///
	mlabel("Discovery(1-Year)" "Discovery(5-Year)" "Production(1-Year)" "Production(5-Year)") ///
	order(oildiscoverydyad oildiscdyadyears2 oildiscdyadyears3 oilproductiondyad oilproduction5 dyaddem mixeddyad relcapenergy majpow cwmid navpower unclosforce americas europe asia middleeast) ///
	label ///
	title("Table A5: Lagged Effect of Maritime Diplomatic Claim Occurrence on Offshore Fossil-Fuel Development, 1900-2007")
	
log close
clear all